1. Field of the Invention
The present invention relates to object-oriented programming systems. More specifically, the present invention relates to a method and an apparatus that facilitates use of compact object headers within an object-oriented programming system.
2. Related Art
The growing popularity of pocket-sized computing devices, such as personal organizers, has lead to the development of a large number of applications for these miniature computing platforms. Unfortunately, memory space is severely constrained within these pocket-sized computing devices. Hence, application developers often take great pains to use as little memory space as possible in writing applications for these pocket-sized computing devices.
Many applications for pocket-sized computing devices are developed using object-oriented programming languages, such as the JAVA™ programming language, that operate on “objects” located within an object heap. Unfortunately, systems that support object-oriented programming languages do not use memory space as efficiently as possible.
In particular, existing object-oriented programming systems typically allocate space within the object header to store an identifier (hash code) for the object. However, this space is typically wasted because only a small fraction of allocated objects actually make use of the object identifier field.
This wasted space is significant because objects tend to be small, often averaging less than 30 bytes in size. Hence, an unused four-byte object identifier within an object header wastes a considerable fraction of the space that is allocated for the average object.
Note that it may be possible to encode the object identifier into another field within the object header. However, doing so requires complicated bit encoding and decoding operations. Furthermore, if the object identifier is encoded with a pointer, the size of the pointer is restricted, which can unnecessarily limit the size of the object heap.
It is also possible to use to the address of the object as the object identifier. However, doing so limits the system's ability to relocate the object during garbage collection operations, which can lead to fragmentation of the memory space within the object heap.
What is needed is a method and an apparatus that eliminates wasted space that is allocated for object identifiers.